<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>学生管理</title>
		<link rel="stylesheet" href="/layuimoduls/lib/layui-v2.6.3/css/layui.css" media="all">
		<link rel="stylesheet" href="/layuimoduls/css/public.css" media="all">
		<script src="/layuimoduls/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
	</head>
	<body>
	<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

	<script type="text/html" id="currentTableBar">
		<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">修改</a>
		<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>
	</script>
	</body>


	<script>
		layui.use(['form', 'table'], function () {
					var $ = layui.jquery,
							table = layui.table;

					table.render({
						elem: '#currentTableId',
						url: '/queryStuAll',
						method: 'get',
						defaultToolbar: ['filter', 'exports', 'print', {
							title: '提示',
							layEvent: 'LAYTABLE_TIPS',
							icon: 'layui-icon-tips'
						}],
						cols: [
								[
							{type: "checkbox",},
							{field: 'studentid', title: '学生ID', sort: true},
							{field: 'username', title: '用户名'},
							{field: 'realname', title: '真实姓名'},
							{field: 'serialnumber', title: '手机号'},
							{field: 'mailnumber', title: '邮箱'},
							{field: 'college', title: '学院'},
							{title: '操作', minWidth: 150, toolbar: '#currentTableBar', align: "center"}
						]],
						limits: [10, 15, 20, 25, 50, 100],
						limit: 15,
						page: true,
						skin: 'line',
						//分页
						parseData: function (res) { //将原始数据解析成 table 组件所规定的数据，res为从url中get到的数据
							var result;
							console.log(this);
							console.log(JSON.stringify(res));
							if (this.page.curr) {
								result = res.data.slice(this.limit * (this.page.curr - 1), this.limit * this.page.curr);
							} else {
								result = res.data.slice(0, this.limit);
							}
							return {
								"code": res.code, //解析接口状态
								"msg": res.msg, //解析提示文本
								"count": res.count, //解析数据长度
								"data": result //解析数据列表
							}
						}
					});

				});
	</script>
</html>
